﻿namespace Devonline.Entity;

/// <summary>
/// 账户交易记录, 字符主键的默认实现
/// </summary>
[Table("account_record"), DisplayName("账户交易记录")]
public class AccountRecord : AccountRecord<string>, IEntitySet, IEntitySetWithCreate
{
    /// <summary>
    /// 账户所属用户个人信息
    /// </summary>
    public virtual Personal? Personal { get; set; }
}

/// <summary>
/// 账户交易记录
/// </summary>
[Table("account_record"), DisplayName("账户交易记录")]
public abstract class AccountRecord<TKey> : EntitySetWithCreate<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 用户个人信息
    /// 冗余个人信息便于查询
    /// </summary>
    [Column("personal_id"), DisplayName("个人信息编号"), MaxLength(36), Excel]
    public virtual TKey? PersonalId { get; set; }
    /// <summary>
    /// 交易账户编号
    /// </summary>
    [Column("account_id"), DisplayName("账户编号"), Required, MaxLength(36), Excel]
    public virtual TKey? AccountId { get; set; }
    /// <summary>
    /// 操作人
    /// </summary>
    [Column("operator"), DisplayName("操作人"), Required, MaxLength(36), Excel]
    public virtual string? Operator { get; set; }
    /// <summary>
    /// 操作时间, 精确到秒
    /// </summary>
    [Column("operate_time"), DisplayName("操作时间"), Excel]
    public virtual DateTime OperateTime { get; set; }
    /// <summary>
    /// 交易金额
    /// </summary>
    [Column("amount", TypeName = "DECIMAL(18,4)"), DisplayName("交易金额"), Excel]
    public virtual decimal Amount { get; set; }
    /// <summary>
    /// 交易类型 TradeType 枚举值
    /// </summary>
    [Column("trade_type", TypeName = "VARCHAR(16)"), DisplayName("交易类型"), Required, DefaultValue(TradeType.Payment), Excel]
    public virtual TradeType TradeType { get; set; }
    /// <summary>
    /// 交易编号, 来自第三方记录订单编号
    /// </summary>
    [Column("trade_no"), DisplayName("交易编号"), MaxLength(36), Excel]
    public virtual string? TradeNo { get; set; }
}